Method, System and Apparatus for Controlling Flow Detection, Controller and Detection Device

ABSTRACT

A control method, system and apparatus for flow detection, a controller and a detection device. The method includes the controller acquires a flow identifier of a flow to be detected by each flow detection module in a network; adjusts the flow to be detected by each flow detection module according to a set load balancing policy; and delivers a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment. In the present invention, because multiple flow detection modules are deployed in a network in a distributed manner, when there are a large number of switching devices included in the network, load balancing can be performed for detection of flows transmitted between these switching devices.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No. PCT/CN2013/089750, filed on Dec. 18, 2013, which claims priority to Chinese Patent Application No. 201210551811.1, filed on Dec. 18, 2012, both of which are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

The present invention relates to the field of network communications technologies, and in particular, to a method, system and apparatus for controlling flow detection, a controller and a detection device.

BACKGROUND

A conventional network architecture generally includes several routing switching devices, and each routing switching device may be connected to several host devices, and all the routing switching devices are directly or indirectly connected to a gateway device, and are connected to an external network by means of the gateway device. In the prior art, a flow detection device may be deployed on a critical path in a network. For example, for a local area network or a corporate network, a flow detection device may be deployed on a connection path of a gateway device and an external network, so as to detect overall flows of the local area network or the corporate network. However, because deploying a flow detection device on a critical path in a network can only detect overall flows of the network, it is difficult to detect flows transmitted between switching devices in the network. Therefore, in an existing manner, a flow detection device is deployed in the network, and all switching devices are connected to the flow detection device, and the flow detection device detects flows transmitted between the switching devices in the network.

During a research on the prior art, the inventor discovers that, although flows transmitted between switching devices in a network can be detected by deploying a flow detection device in the network, when there are a large number of switching devices in the network, the number of flows that need to be detected by the flow detection device is large, and therefore the flow detection device is load-imbalanced and is easy to break down.

SUMMARY

Embodiments of the present invention provide a method, system and apparatus for controlling flow detection, a controller and a detection device, so as to resolve problems in the prior art that flow detection load is imbalanced and that a flow detection device in a network is easy to break down.

To resolve the foregoing technical problems, the embodiments of the present invention disclose the following technical solutions.

According to a first aspect, a method for controlling flow detection is provided, where the method is applied to a network including multiple flow detection modules, and the method includes acquiring, by a controller, a flow identifier of a flow to be detected by each flow detection module in the network, where each flow detection module corresponds to at least one switching device; adjusting, by the controller, according to a set load balancing policy, the flow to be detected by each flow detection module; and delivering, by the controller, a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

With reference to the first aspect, in a first possible implementation manner of the first aspect, the acquiring, by a controller, a flow identifier of a flow to be detected by each flow detection module in the network includes looking up, by the controller, a stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; and acquiring, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device, and determining that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

With reference to the first aspect, or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the adjusting, by the controller, according to a set load balancing policy, the flow to be detected by each flow detection module is invoking, by the controller, a weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.

According to a second aspect, a method for controlling flow detection is provided, where the method is applied to each flow detection module in a network including multiple flow detection modules, where each flow detection module corresponds to at least one switching device, and the method includes receiving, by a flow detection module, a detection instruction delivered by a controller in the network, where the detection instruction includes a flow identifier of a flow to be detected by the flow detection module in the network after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each flow detection module; and detecting, by the flow detection module, a flow corresponding to the flow identifier included in the detection instruction.

With reference to the second aspect, in a first possible implementation manner of the second aspect, the flow detection module is disposed on a corresponding switching device; or the flow detection module is disposed on a detection device connected to the corresponding switching device.

According to a third aspect, a system for controlling flow detection is provided, where the system includes a controller, multiple switching devices and multiple flow detection modules, where each flow detection module corresponds to at least one switching device; each of the switching devices is configured to forward a flow in a network; the controller is configured to acquire a flow identifier of a flow to be detected by each flow detection module in the network, adjust, according to a set load balancing policy, the flow to be detected by each flow detection module, and deliver a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment; and each of the flow detection modules is configured to detect a flow corresponding to the flow identifier included in the detection instruction delivered by the controller.

With reference to the third aspect, in a first possible implementation manner of the third aspect, the controller is configured to look up a stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device; and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

With reference to the third aspect or the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, the flow detection module is disposed on a corresponding switching device; or the flow detection module is disposed on a detection device connected to the corresponding switching device.

According to a fourth aspect, an apparatus for controlling flow detection is provided, where the apparatus is applied to a network including multiple flow detection modules, and the apparatus includes an acquiring unit, configured to acquire a flow identifier of a flow to be detected by each flow detection module in the network, where each flow detection module corresponds to at least one switching device; an adjusting unit, configured to adjust, according to a set load balancing policy, the flow to be detected by each flow detection module; and a controlling unit, configured to deliver a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

With reference to the fourth aspect, in a first possible implementation manner of the fourth aspect, the acquiring unit includes a rule lookup subunit, configured to look up a stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; and an identifier acquiring subunit, configured to acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device, and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

With reference to the fourth aspect or the first possible implementation manner of the fourth aspect, in a second possible implementation manner of the fourth aspect, the adjusting unit is configured to invoke a weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.

With reference to the fourth aspect, or the first possible implementation manner of the fourth aspect, or the second possible implementation manner of the fourth aspect, in a third possible implementation manner of the fourth aspect, the apparatus for controlling is disposed on a controller in the network.

According to a fifth aspect, a controller is provided, where the controller is applied to a network including multiple flow detection modules, and the controller includes a bus, and a network interface, a memory and a processor that are connected by means of the bus, where the network interface is configured to connect multiple switching devices in the network, where each flow detection module corresponds to at least one switching device; the memory is configured to store a set load balancing policy; and the processor is configured to acquire a flow identifier of a flow to be detected by each flow detection module in the network, adjust, according to the load balancing policy, the flow to be detected by each flow detection module, and deliver a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

With reference to the fifth aspect, in a first possible implementation manner of the fifth aspect, the memory is further configured to store a flow forwarding rule in the network; and the processor is configured to look up the stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device; and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

With reference to the fifth aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner of the fifth aspect, the memory is configured to store a set weighted average policy; and the processor is configured to invoke the weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.

According to a sixth aspect, a flow detection apparatus is provided, where the apparatus is applied to a network including multiple flow detection apparatuses, where each of the flow detection apparatuses corresponds to at least one switching device, and the apparatus includes a receiving unit, configured to receive a detection instruction delivered by a controller in the network, where the detection instruction includes a flow identifier of a flow to be detected by the flow detection module in the network after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each flow detection module; and a detection unit, configured to detect a flow corresponding to the flow identifier included in the detection instruction.

With reference to the sixth aspect, in a first possible implementation manner of the sixth aspect, the flow detection apparatus is disposed on a corresponding switching device; or the flow detection apparatus is disposed on a detection device connected to the corresponding switching device.

According to a seventh aspect, a detection device is provided, where the detection device is applied to a network including multiple detection devices, where each of the detection devices corresponds to at least one switching device, and the detection device includes a bus, and a network interface and a processor that are connected by means of the bus, where the network interface is configured to connect a controller in the network and a switching device corresponding to the detection device; and the processor is configured to receive a detection instruction delivered by the controller, where the detection instruction includes a flow identifier of a flow to be detected by the flow detection module after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each flow detection module; and detect a flow corresponding to the flow identifier included in the detection instruction.

In the embodiments of the present invention, a controller acquires a flow identifier of a flow to be detected by each flow detection module in a network, adjusts, according to a set load balancing policy, the flow to be detected by each flow detection module, and delivers a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment. In the embodiments of the present invention, because multiple flow detection modules are deployed in a network in a distributed manner, when there are a large number of switching devices included in the network, load balancing can be performed for detection of flows transmitted between these switching devices, so that flows transmitted in the network can be evenly distributed to the flow detection modules as much as possible, thereby decreasing the number of flows to be detected by a single flow detection module and ensuring normal flow detection in the network.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the present invention or in the prior art more clearly, the following briefly introduces the accompanying drawings required for describing the embodiments or the prior art. A person of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts.

FIG. 1 is a flowchart of an embodiment of a method for controlling flow detection according to the present invention;

FIG. 2 is a flowchart of another embodiment of a method for controlling flow detection according to the present invention;

FIG. 3 is a schematic diagram of a network architecture applied in an embodiment of the present invention;

FIG. 4 is a block diagram of an embodiment of a system for controlling flow detection according to the present invention;

FIG. 5 is a block diagram of an embodiment of an apparatus for controlling flow detection according to the present invention;

FIG. 6 is a block diagram of an embodiment of a controller according to the present invention;

FIG. 7 is a block diagram of an embodiment of a flow detection apparatus according to the present invention; and

FIG. 8 is a block diagram of an embodiment of a detection device according to the present invention.

DESCRIPTION OF EMBODIMENTS

The following embodiments of the present invention provide a control method, system and apparatus for flow detection, a controller and a detection device.

To enable a person skilled in the art to better understand technical solutions in embodiments of the present invention, and make the foregoing purposes, features, and advantages of the embodiments of the present invention clearer and more comprehensible, the following describes the technical solutions of the embodiments of the present invention in more detail with reference to accompanying drawings.

The following embodiments of the present invention may be applied to a software-defined network (SDN). An SDN network separates a control plane of a network device from a data forwarding plane of the network device, so that network flows can be controlled flexibly. A function of the control plane is implemented by a controller, which is mainly responsible for delivering a flow forwarding policy, and in the embodiments of the present invention, the controller further has a function of controlling network flow detection. A function of the data forwarding plane is implemented by a switch (SW), which is mainly configured to receive the flow forwarding policy delivered by the controller, and forward a flow according to the forwarding policy. Generally in an SDN network, a controller is separately connected to each switch, and flow forwarding between switches is implemented by mutual connection. In the embodiments of the present invention, multiple flow detection modules may be deployed in an SDN network, and each flow detection module is connected to one switch, and may be configured to detect network traffic flowing through the switch; and the flow detection module may be integrated into the switch, or may also be disposed in a device independent of the switch, for example, the flow detection module may be disposed in a firewall (FW) device, an intrusion prevention system (IPS) device, an Intrusion Detection System (IDS) device, or the like, and in this case, the device is connected to a corresponding switch.

FIG. 1 is a flowchart of an embodiment of a method for controlling flow detection according to the present invention, and this embodiment describes a process of controlling flow detection on a controller side in a network.

Step 101: A controller acquires a flow identifier of a flow to be detected by each flow detection module in the network.

In this embodiment, each flow detection module corresponds to at least one switching device.

The controller is connected to each switching device, and the controller stores flow forwarding rules of all flows in the network, where the flow forwarding rules include a flow identifier and a transmission path of each flow. The flow identifier may include a source address and a destination address of the flow, and the transmission path may include a device identifier of a switching device through which the flow is transmitted from the source address to the destination address. When the controller needs to acquire a flow identifier of a flow to be detected by each flow detection module, the controller may look up a stored flow forwarding rule, and acquire a flow identifier of a flow corresponding to a device identifier of a same switching device, and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

Step 102: The controller adjusts, according to a set load balancing policy, the flow to be detected by each flow detection module.

In this embodiment, the controller may invoke a weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment. It should be noted that, any load balancing policy of the prior art may be used in this embodiment of the present invention, so long as flows to be detected by flow detection modules can be balanced using the load balancing policy, which is not limited in this embodiment of the present invention.

Step 103: The controller delivers a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

Because originally traffic flowing through each switching device is different in the network, the numbers of flows to be detected by network flow detection modules are also different. Especially for flows of flow detection modules that are disposed in at least two switching devices on the transmission path, it may be implemented that the flows are detected by only one of the flow detection modules by means of load balancing.

It can be learned from the foregoing embodiment that, because multiple flow detection modules are deployed in a network in a distributed manner, when there are a large number of switching devices included in the network, load balancing can be performed for detection of flows transmitted between these switching devices, so that flows transmitted in the network can be evenly distributed to the flow detection modules as much as possible, thereby decreasing the number of flows to be detected by a single flow detection module and ensuring normal flow detection in the network.

FIG. 2 is a flowchart of another embodiment of a method for controlling flow detection according to the present invention, and this embodiment describes a process of controlling flow detection on a side of any flow detection module in a network.

Step 201: A flow detection module receives a detection instruction delivered by a controller in the network, where the detection instruction includes a flow identifier of a flow to be detected by the flow detection module in the network after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each flow detection module.

In this embodiment, the flow detection module may be disposed on a corresponding switching device, or the flow detection module may also be disposed on a detection device connected to the corresponding switching device.

In this embodiment, each controller is connected to multiple flow detection modules, and therefore, after performing load balancing for detection of all flows in the network, the controller delivers a detection instruction to each flow detection module. The detection instruction may include only the flow identifier of the flow to be detected by the flow detection module; or the detection instruction may also include a flow identifier of a flow to be detected by each flow detection module in all flow detection modules. Any flow detection module may acquire, according to a module identifier of itself, a flow identifier of a flow to be detected.

Step 202: The flow detection module detects the flow corresponding to the flow identifier included in the detection instruction.

After the flow detection module receives the detection instruction, the flow identifier included in the detection module may be used to update an originally stored flow identifier of a flow to be detected by the flow detection module, so that flow detection is performed according to an updated flow identifier.

It can be learned from the foregoing embodiment that, because multiple flow detection modules are deployed in a network in a distributed manner, when there are a large number of switching devices included in the network, load balancing can be performed for detection of flows transmitted between these switching devices, so that flows transmitted in the network can be evenly distributed to the flow detection modules as much as possible, thereby decreasing the number of flows to be detected by a single flow detection module and ensuring normal flow detection in the network.

FIG. 3 is a schematic diagram of a network architecture applied to the foregoing method embodiment of the present invention.

The network architecture in FIG. 3 may be an architecture based on an SDN network, and as an example, the network architecture is divided into an internal network and an external network, where the internal network includes a controller, three switches, which are respectively a SW1, a SW2, and a SW3, and three flow detection modules, which are respectively a flow detection module 1 corresponding to the SW1, a flow detection module 2 corresponding to the SW2, and a flow detection module 3 corresponding to the SW3. The foregoing controller and the three switches are all connected to a gateway (GW), and connected to the external network by means of the GW. Each switch is connected to two host devices, including a host device A and a host device 1 that are connected to the SW1, a host device B and a host device 2 that are connected to the SW2, and a host device C and a host device 3 that are connected to the SW3. The controller is mutually connected to each switch, and a flow detection module of each switch may also separately communicate with the controller, where a function of the flow detection module of each switch may be integrated into the switch, or may also be configured in a detection device connected to the switch, that is, one detection device may be configured for each switch, which is not limited in this embodiment of the present invention.

The following describes a process for controlling flow detection described in this embodiment of the present invention with reference to the network architecture shown in FIG. 3.

Firstly, the controller may acquire a flow identifier and a transmission path of each flow from a stored flow forwarding rule, and obtain, according to the flow identifier and the transmission path, a flow detection module that detects each flow, where a result is shown in the following Table 1:

TABLE 1 Flow identifier Transmission path Flow detection module  A<−>N SW1, GW Flow detection module 1 A<−>1 SW1 Flow detection module 1  A<−>C SW1, SW3 Flow detection module 1, flow detection module 3  B<−>N SW2, GW Flow detection module 2 B<−>2 SW2 Flow detection module 2 B<−>1 SW2, SW1 Flow detection module 2, flow detection module 1  C<−>N SW3, GW Flow detection module 3 C<−>3 SW3 Flow detection module 3  2<−>3 SW2, SW3 Flow detection module 2, flow detection module 3

In the foregoing Table 1, a flow identifier being A<->N is used as an example, where “A” indicates an address of the host A that is used as a source address, “N” indicates an address of the Network that is used as a destination address; a transmission path being “SW1, GW” is used as an example, which indicates that a flow “A<->N” needs to go through the switching device SW1 and the GW in a process of transmission from the host A to the Network, and because the flow detection module 1 is configured for the SW1, the flow “A<->N” is detected by the flow detection module 1 before load balancing is performed for flow detection.

According to the foregoing Table 1, before load balancing, flows that need to be detected originally by the flow detection module 1 are A<->N, A<->1, A<->C and B<->1; flows that need to be detected originally by the flow detection module 2 are B<->N, B<->2, B<->1 and 2<->3; flows that need to be detected originally by the flow detection module 3 are A<->C, C<->N, C<->3 and 2<->3. Which policy is adopted to perform load balancing for detection of the flows is not limited in this embodiment of the present invention, and therefore, in an optional policy example, it is assumed that a weighted average policy is adopted to perform load balancing for the foregoing flows, and then the following load balancing results may be acquired: the flow detection module 1 detects flows A<->N, A<->1, A<->C, the flow detection module 2 detects flows B<->N, B<->2, B<->1, and the flow detection module 3 detects flows C<->N, C<->3 and 2<->3.

After the controller executes the foregoing load balancing policy, it can be ensured that each flow detection module detects three flows, and in this case, the controller delivers a detection instruction that includes flow identifiers A<->N, A<->1, and A<->C to the flow detection module 1, a detection instruction that includes flow identifiers B<->N, B<->2, and B<->1 to the flow detection module 2, and a detection instruction that includes flow identifiers C<->N, C<->3 and 2<->3 to the flow detection module 3. The flow detection module 1 is used as an example. The flow detection module 1 detects only the flows with the flow identifiers of A<->N, A<->1, and A<->C, and no longer detects the flow with the flow identifier of B<->1.

It can be learned from the foregoing embodiment that, because multiple flow detection modules are deployed in a network in a distributed manner, when there are a large number of switching devices included in the network, load balancing can be performed for detection of flows transmitted between these switching devices, so that flows transmitted in the network can be evenly distributed to the flow detection modules as much as possible, thereby decreasing the number of flows to be detected by a single flow detection module and ensuring normal flow detection in the network.

Corresponding to the embodiment of the method for controlling flow detection according to the present invention, embodiments of a system and apparatus for controlling flow detection, a controller and a detection device are further provided in the present invention.

FIG. 4 is a block diagram of an embodiment of a system for controlling flow detection according to the present invention.

The system includes a controller 410, multiple switching devices 420 and multiple flow detection modules 430, where each flow detection module may correspond to at least one switching device. For ease of illustration in FIG. 4, three switching devices are illustrated, and a flow detection module is disposed in each switching device. It should be noted that each flow detection module may also be disposed in a detection device, which is independent of a switching device and connected to the switching device. This is not limited in this embodiment of the present invention.

Each of the switching devices 420 is configured to forward a flow in a network.

The controller 410 is configured to acquire a flow identifier of a flow to be detected by each flow detection module in the network, adjust, according to a set load balancing policy, the flow to be detected by each flow detection module, and deliver a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

Each of the flow detection modules 430 is configured to detect a flow corresponding to the flow identifier included in the detection instruction delivered by the controller.

Optionally, the controller 410 is configured to look up a stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device; and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

FIG. 5 is a block diagram of an embodiment of an apparatus for controlling flow detection according to the present invention. The apparatus may be applied to the system illustrated in the foregoing FIG. 4, for example, the apparatus may be disposed on the controller in the network illustrated in the foregoing FIG. 4.

The apparatus for controlling includes an acquiring unit 510, an adjusting unit 520 and a controlling unit 530, where the acquiring unit 510 is configured to acquire a flow identifier of a flow to be detected by each flow detection module in the network, where each flow detection module corresponds to at least one switching device; the adjusting unit 520 is configured to adjust, according to a set load balancing policy, the flow to be detected by each flow detection module; and the controlling unit 530 is configured to deliver a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

Optionally, the acquiring unit 510 may further include (not illustrated in FIG. 5) a rule lookup subunit, configured to look up a stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; and an identifier acquiring subunit, configured to acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device, and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

Optionally, the adjusting unit 520 may be configured to invoke a weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.

FIG. 6 is a block diagram of an embodiment of a controller according to the present invention. The controller may be applied to the network illustrated in the foregoing FIG. 4 that includes multiple flow detection modules.

The controller includes a bus 610, and a network interface 620, a memory 630 and a processor 640 that are connected by means of the bus 610, where the network interface 620 is configured to connect multiple switching devices in the network, where each flow detection module corresponds to at least one switching device; the memory 630 is configured to store a set load balancing policy; and the processor 640 is configured to acquire a flow identifier of a flow to be detected by each flow detection module in the network, adjust, according to the load balancing policy, the flow to be detected by each flow detection module, and deliver a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment.

Optionally, the memory 630 is further configured to store a flow forwarding rule in the network; and the processor 640 is configured to look up a stored flow forwarding rule, where the flow forwarding rule includes a flow identifier and a transmission path of each flow, where the flow identifier includes a source address and a destination address of the flow, and the transmission path includes a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device; and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.

Optionally, the memory 630 is configured to store a set weighted average policy; and the processor 640 is configured to invoke the weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.

FIG. 7 is a block diagram of an embodiment of a flow detection apparatus according to the present invention. The flow detection apparatus may be applied to the system illustrated in the foregoing FIG. 4. The flow detection apparatus has a function of a flow detection module, and may be disposed in at least one corresponding switching device, or may also be disposed in a detection device, which is independent of a switching device and connected to the switching device.

The flow detection apparatus includes a receiving unit 710 and a detection unit 720, where the receiving unit 710 is configured to receive a detection instruction delivered by a controller in a network, where the detection instruction includes a flow identifier of a flow to be detected by the flow detection apparatus in the network after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each flow detection apparatus; and the detection unit 720 is configured to detect a flow corresponding to the flow identifier included in the detection instruction.

FIG. 8 is a block diagram of an embodiment of a detection device according to the present invention. The detection device may be applied to the system illustrated in the foregoing FIG. 4. The detection device includes a function of a flow detection module, and the detection device corresponds to at least one switching device and is connected to the at least one switching device.

The detection device includes a bus 810, and a network interface 820 and a processor 830 that are connected by means of the bus 810, where the network interface 820 is configured to connect a controller in a network and the switching device corresponding to the detection device; and the processor 830 is configured to receive a detection instruction delivered by the controller, where the detection instruction includes a flow identifier of a flow to be detected by the detection device in the network after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each detection device; and detect a flow corresponding to the flow identifier included in the detection instruction.

It can be learned from the foregoing embodiment that, a controller acquires a flow identifier of a flow to be detected by each flow detection module in a network, adjusts, according to a set load balancing policy, the flow to be detected by each flow detection module, and delivers a detection instruction to each flow detection module, where the detection instruction includes a flow identifier of a flow to be detected by each flow detection module after the adjustment. In the embodiments of the present invention, because multiple flow detection modules are deployed in a network in a distributed manner, when there are a large number of switching devices included in the network, load balancing can be performed for detection of flows transmitted between these switching devices, so that flows transmitted in the network can be evenly distributed to the flow detection modules as much as possible, thereby decreasing the number of flows to be detected by a single flow detection module and ensuring normal flow detection in the network.

A person skilled in the art may clearly understand that, the technique in the embodiments of the present invention may be implemented through software and a necessary general hardware platform. Based on such an understanding, the technical solutions of the present invention essentially or the part contributing to the prior art may be implemented in a form of a software product. The software product is stored in a storage medium, such as a read-only memory (ROM), random access memory (RAM), a hard disk, or an optical disc, and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform the methods described in the embodiments or some parts of the embodiments of the present invention.

The embodiments in this specification are all described in a progressive manner, for same or similar parts in the embodiments, reference may be made to these embodiments, and each embodiment focuses on a difference from other embodiments. Especially, a system embodiment is basically similar to a method embodiment, and therefore is described briefly; for related parts, reference may be made to partial descriptions in the method embodiment.

The foregoing descriptions are implementation manners of the present invention, but are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, and improvement made without departing from the spirit and principle of the present invention shall fall within the protection scope of the present invention. 

What is claimed is:
 1. A method for controlling flow detection, wherein the method is applied to a network comprising multiple flow detection modules, the method comprising: acquiring, by a controller, a flow identifier of a flow to be detected by each flow detection module in the network, wherein each flow detection module corresponds to at least one switching device; adjusting, by the controller according to a set load balancing policy, the flow to be detected by each flow detection module; and delivering, by the controller, a detection instruction to each flow detection module, wherein the detection instruction comprises a flow identifier of a flow to be detected by each flow detection module after the adjustment.
 2. The method according to claim 1, wherein acquiring, by the controller, the flow identifier of the flow to be detected by each flow detection module in the network comprises: looking up, by the controller, a stored flow forwarding rule, wherein the flow forwarding rule comprises a flow identifier and a transmission path of each flow, wherein the flow identifier comprises a source address and a destination address of the flow, and wherein the transmission path comprises a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; and acquiring, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device, and determining that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.
 3. The method according to claim 2, wherein adjusting, by the controller, according to the set load balancing policy, the flow to be detected by each flow detection module comprises invoking, by the controller, a weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.
 4. The method according to claim 1, wherein adjusting, by the controller, according to the set load balancing policy, the flow to be detected by each flow detection module comprises invoking, by the controller, a weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.
 5. A system for controlling flow detection, wherein the system comprises: a controller; multiple switching devices; and multiple flow detection modules, wherein each flow detection module corresponds to at least one switching device, wherein each of the switching devices is configured to forward a flow in a network, wherein the controller is configured to: acquire a flow identifier of a flow to be detected by each flow detection module in the network; adjust, according to a set load balancing policy, the flow to be detected by each flow detection module; and deliver a detection instruction to each flow detection module, wherein the detection instruction comprises a flow identifier of a flow to be detected by each flow detection module after the adjustment, and wherein each of the flow detection modules is configured to detect a flow corresponding to the flow identifier that is part of the detection instruction delivered by the controller.
 6. The system according to claim 5, wherein the controller is configured to: look up a stored flow forwarding rule, wherein the flow forwarding rule comprises a flow identifier and a transmission path of each flow, wherein the flow identifier comprises a source address and a destination address of the flow, and wherein the transmission path comprises a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device; and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.
 7. The system according to claim 6, wherein the flow detection module is disposed on the corresponding switching device.
 8. The system according to claim 6, wherein the flow detection module is disposed on a detection device connected to the corresponding switching device.
 9. The system according to claim 5, wherein the flow detection module is disposed on the corresponding switching device.
 10. The system according to claim 5, wherein the flow detection module is disposed on a detection device connected to the corresponding switching device.
 11. A controller, wherein the controller is applied to a network comprising multiple flow detection modules, and the controller comprises: a bus; a network interface; a memory; and a processor that are connected by means of the bus, wherein the network interface is configured to connect multiple switching devices in the network, wherein each flow detection module corresponds to at least one switching device, wherein the memory is configured to store a set load balancing policy, and wherein the processor is configured to: acquire a flow identifier of a flow to be detected by each flow detection module in the network; adjust, according to the load balancing policy, the flow to be detected by each flow detection module; and deliver a detection instruction to each flow detection module, wherein the detection instruction comprises a flow identifier of a flow to be detected by each flow detection module after the adjustment.
 12. The controller according to claim 11, wherein the memory is further configured to store a flow forwarding rule in the network, and wherein the processor is specifically configured to: look up the stored flow forwarding rule, wherein the flow forwarding rule comprises a flow identifier and a transmission path of each flow, wherein the flow identifier comprises a source address and a destination address of the flow, and wherein the transmission path comprises a device identifier of a switching device through which the flow is transmitted from the source address to the destination address; acquire, from the flow forwarding rule, a flow identifier of a flow corresponding to a device identifier of a same switching device; and determine that the flow corresponding to the device identifier of the same switching device is a flow to be detected by a flow detection module corresponding to the switching device.
 13. The controller according to claim 12, wherein the memory is configured to store a set weighted average policy, and wherein the processor is configured to invoke the weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.
 14. The controller according to claim 11, wherein the memory is configured to store a set weighted average policy, and wherein the processor is configured to invoke the weighted average policy to adjust the flow to be detected by each flow detection module, so that the number of flows to be detected by each flow detection module is consistent after the adjustment.
 15. A detection device, wherein the detection device is applied to a network comprising multiple detection devices, wherein each of the detection devices corresponds to at least one switching device, and wherein the detection device comprises: a bus; a network interface; and a processor that are connected by means of the bus, wherein the network interface is configured to connect a controller in the network and a switching device corresponding to the detection device, and wherein the processor is configured to: receive a detection instruction delivered by the controller, wherein the detection instruction comprises a flow identifier of a flow to be detected by the detection device in the network after adjustment that is performed by the controller according to a set load balancing policy after acquiring a flow identifier of a flow to be detected by each detection device; and detect a flow corresponding to the flow identifier that is part of the detection instruction. 